﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Data;
using System.Collections;

public partial class admin_PipelineMP : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = null;
        Hashtable ht = null;
        if (Session["userid"] == null) Response.Redirect("../default.aspx");


        if (!Page.IsPostBack)
        {
            ht = (Hashtable)DB.getContadorDataMP();
            dt = (DataTable)Utility.HasgtoDataSet(ht);
            RE_GenericBean rgb = Utility.addTotales(dt);
            lbgoal.Text = rgb.intC1.ToString();
            lbmonday.Text = rgb.intC2.ToString();
            lbtuesday.Text = rgb.intC3.ToString();
            lbwednesday.Text = rgb.intC4.ToString();
            lbthursday.Text = rgb.intC5.ToString();
            lbfriday.Text = rgb.intC6.ToString();
            lbsaturday.Text = rgb.intC7.ToString();
            lbtotal.Text = rgb.intC8.ToString();
            lbdiff.Text = rgb.intC9.ToString();
            //object[] objArr1 = { "Total", rgb.intC1, rgb.intC2, rgb.intC3, rgb.intC4, rgb.intC5, rgb.intC6, rgb.intC7, rgb.intC8, rgb.intC9 };
            //dt.Rows.Add(objArr1);
            gvContador.DataSource = dt;
            gvContador.DataBind();
            Session["dsContadorMP"] = dt;
        }
    }


    protected void gvContador_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        DataTable ds = null;
        if (Session["dsContadorMP"] != null) ds = (DataTable)Session["dsContadorMP"];
        gvContador.PageIndex = e.NewPageIndex;
        gvContador.DataSource = ds;
        gvContador.DataBind();
    }

    protected void gvContador_DataBound(object sender, EventArgs e)
    {
        int maximo = 5;
        int minimo = 0;
        GridViewRow row = null;
        if (gvContador.Rows.Count <= 5)
        {
            maximo = gvContador.Rows.Count;
        }

        if (gvContador.Rows.Count > 5)
        {
            minimo = gvContador.Rows.Count - 5;
        }
        int contador = 1;
        foreach (GridViewRow gvr in gvContador.Rows)
        {
            gvr.BackColor = System.Drawing.Color.FromName("#f7fa03"); //amarillo
            gvr.Cells[0].Text = contador.ToString();
            contador++;
            //gvr.Cells[0].BackColor = System.Drawing.Color.White;
            //gvr.Cells[1].BackColor= System.Drawing.Color.White;
            //gvr.Cells[2].BackColor = System.Drawing.Color.White;
            gvr.Cells[0].ForeColor = System.Drawing.Color.FromName("#051bf2");
            gvr.Cells[1].ForeColor = System.Drawing.Color.FromName("#051bf2");
            gvr.Cells[2].ForeColor = System.Drawing.Color.FromName("#051bf2");
            //gvr.Cells[10].BackColor = System.Drawing.Color.White;
            gvr.Cells[10].ForeColor = System.Drawing.Color.FromName("#051bf2");

            gvr.Cells[0].Width = 30;
            gvr.Cells[1].Width = 300;
            gvr.Cells[2].Width = 60;
            gvr.Cells[3].Width = 60;
            gvr.Cells[4].Width = 60;
            gvr.Cells[5].Width = 60;
            gvr.Cells[6].Width = 60;
            gvr.Cells[7].Width = 60;
            gvr.Cells[8].Width = 60;
            gvr.Cells[9].Width = 60;
            gvr.Cells[10].Width = 60;

            gvr.Cells[0].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[2].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[3].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[4].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[5].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[6].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[7].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[8].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[9].HorizontalAlign = HorizontalAlign.Center;
            gvr.Cells[10].HorizontalAlign = HorizontalAlign.Center;


            gvr.Cells[0].Font.Size = 12;
            gvr.Cells[1].Font.Size = 10;
            gvr.Cells[2].Font.Size = 12;
            gvr.Cells[3].Font.Size = 12;
            gvr.Cells[4].Font.Size = 12;
            gvr.Cells[5].Font.Size = 12;
            gvr.Cells[6].Font.Size = 12;
            gvr.Cells[7].Font.Size = 12;
            gvr.Cells[8].Font.Size = 12;
            gvr.Cells[9].Font.Size = 12;
            gvr.Cells[10].Font.Size = 12;

            gvr.Cells[0].Font.Bold = true;
            gvr.Cells[1].Font.Bold = true;
            gvr.Cells[2].Font.Bold = true;
            gvr.Cells[3].Font.Bold = true;
            gvr.Cells[4].Font.Bold = true;
            gvr.Cells[5].Font.Bold = true;
            gvr.Cells[6].Font.Bold = true;
            gvr.Cells[7].Font.Bold = true;
            gvr.Cells[8].Font.Bold = true;
            gvr.Cells[9].Font.Bold = true;
            gvr.Cells[10].Font.Bold = true;

        }

        for (int a = gvContador.Rows.Count - 1; a > minimo; a--)
        {
            row = (GridViewRow)gvContador.Rows[a];
            row.BackColor = System.Drawing.Color.FromName("#f93a3e"); //rojo
        }

        for (int i = 0; i < maximo; i++)
        {
            row = (GridViewRow)gvContador.Rows[i];
            row.BackColor = System.Drawing.Color.FromName("#0bf410"); //verde
        }

    }
}